@echo off
chcp 65001 >nul
echo 检查学习平台服务状态

echo.
echo ========================================
echo 检查端口占用情况
echo ========================================
echo 前端 (5173):
netstat -an | findstr :5173
echo.
echo 后端 (8080):
netstat -an | findstr :8080
echo.
echo AI服务 (8000):
netstat -an | findstr :8000

echo.
echo ========================================
echo 测试API连接
echo ========================================
echo 测试后端健康检查...
powershell -Command "try { $r = Invoke-RestMethod 'http://localhost:8080/api/v1/health'; Write-Host '后端状态: OK' -ForegroundColor Green; $r } catch { Write-Host '后端状态: 失败' -ForegroundColor Red; $_.Exception.Message }"

echo.
echo 测试前端连接...
powershell -Command "try { $r = Invoke-WebRequest 'http://localhost:5173' -UseBasicParsing; if($r.StatusCode -eq 200) { Write-Host '前端状态: OK' -ForegroundColor Green } else { Write-Host '前端状态: 异常' -ForegroundColor Yellow } } catch { Write-Host '前端状态: 失败' -ForegroundColor Red }"

echo.
echo 测试AI服务...
powershell -Command "try { $r = Invoke-RestMethod 'http://localhost:8000/health'; Write-Host 'AI服务状态: OK' -ForegroundColor Green; $r } catch { Write-Host 'AI服务状态: 失败' -ForegroundColor Red; $_.Exception.Message }"

echo.
pause


